import request from '@/utils/request'

// 根据身份角色获取用户列表
export const GetRoleUserInfos = (role, active = '0', exportFlag = 0) => {
  return request({
    url: 'v1/ruizy/userListInfo/',
    method: 'get',
    params: { role, active, export_flag: exportFlag },
  })
}

// 获取用户信息，可查自己或者管理员查用户
export function GetUserObjInformation(uid = null) {
  return request({
    url: '/v1/ruizy/userInfo/',
    method: 'get',
    params: { uid },
  })
}

// 保存用户的基本信息
export const SaveUserBaseInfo = (data) => {
  return request({
    url: '/v1/ruizy/user/',
    method: 'post',
    data,
  })
}

// 获取用户角色(系统\身份)的菜单权限情况
export const GetRoleMenuAccess = (role) => {
  return request({
    url: '/v1/ruizy/roleMenus/',
    method: 'get',
    params: { role },
  })
}

// 设置角色权限
export const SetRoleMenuAccess = ({ role_code, menu_code, expire }) => {
  return request({
    url: '/v1/ruizy/roleMenus/',
    method: 'post',
    data: { role_code, menu_code, expire },
  })
}

// 获取私人特别菜单权限
export const GetPrivateMenuAccess = (uid = null) => {
  return request({
    url: '/v1/ruizy/privateMenus/',
    method: 'get',
    params: { uid },
  })
}

// 设置私人特别菜单权限
export const SetPrivateMenuAccess = ({ user_id, menu_code, expire }) => {
  return request({
    url: '/v1/ruizy/privateMenus/',
    method: 'post',
    data: { user_id, menu_code, expire },
  })
}

// 根据用户名称搜索用户
export const GetUserListByName = (username) => {
  return request({
    url: '/v1/ruizy/userListByName/',
    method: 'get',
    params: { username },
  })
}

// 获取用户的菜单权限（综合结果）
export const GetUserMenuAccessRouter = async (uid = null) => {
  return request({
    url: '/v1/ruizy/userMenus/',
    method: 'get',
    params: { uid },
  })
}
